[20260330] BOJ / P3 / 마블 / 권혁준#2052
Merged
ShinHeeEul merged 1 commit intomainfrom Mar 30, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🧷 문제 링크
https://www.acmicpc.net/problem/2843
🧭 풀이 시간
20분
👀 체감 난이도
✏️ 문제 설명
정점 N개인 방향 그래프가 주어진다. 각 정점에서 나가는 간선은 최대 한 개이다.
두 종류의 질의를 처리해보자.
🔍 풀이 방법
정점마다 나가는 간선이 최대 한 개라는 것은, 그래프의 한 컴포넌트에는 최대 한 개의 사이클만 존재한다는 것을 의미한다.
매번 탐색을 돌려서 도착점을 구하면 시간 초과니까, 도착점이 루트가 되도록 유니온 파인드를 사용해서 해결했다.
유니온할 때 사이클이 생기는 경우에는 도달 불가능함을 의미하는 가상의 정점 하나에 도달하도록 다시 유니온해줬다.
⏳ 회고
재밌다